package utils

import (
	"Project/global"
	sf "github.com/bwmarrin/snowflake"
	"go.uber.org/zap"
	"time"
)

var node *sf.Node

func Snow() {
	var st time.Time
	st, err := time.Parse("2006-01-02", global.GVA_CONFIG.System.StartTime)
	if err != nil {
		global.GVA_LOG.Info("雪花算法失败", zap.Error(err))
		return
	}
	sf.Epoch = st.UnixNano() / 1000000
	node, err = sf.NewNode(global.GVA_CONFIG.System.MachineID)
	return
}
func GenID() int64 {
	return node.Generate().Int64()
}
